package owl2vowl.model.annotation;

import owl2vowl.model.annotation.Annotation;
import owl2vowl.model.annotation.AnnotationIdentifierEnum;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class Annotations {
	private List<Annotation> labels = new ArrayList();
	private List<Annotation> comments = new ArrayList();
	private List<Annotation> description = new ArrayList();
	private boolean deprecated = false;
	private Map<String, List<Annotation>> identifierToAnnotation = new HashMap();

	public List<Annotation> getComments() {
		return Collections.unmodifiableList(this.comments);
	}

	public List<Annotation> getDescription() {
		return Collections.unmodifiableList(this.description);
	}

	public boolean isDeprecated() {
		return this.deprecated;
	}

	public List<Annotation> getLabels() {
		return Collections.unmodifiableList(this.labels);
	}

	public void addLabel(Annotation annotation) {
		this.labels.add(annotation);
	}

	public Map<String, List<Annotation>> getIdentifierToAnnotation() {
		return Collections.unmodifiableMap(this.identifierToAnnotation);
	}

	public void addAnnotation(Annotation annotation) {
		String identifier = annotation.getIdentifier();
		if (!this.identifierToAnnotation.containsKey(identifier)) {
			this.identifierToAnnotation.put(identifier, new ArrayList());
		}

		((List) this.identifierToAnnotation.get(identifier)).add(annotation);
	}

	public void fillAnnotations(Set<Annotation> annotations) {
		Iterator arg1 = annotations.iterator();

		while (arg1.hasNext()) {
			Annotation annotation = (Annotation) arg1.next();
			if (annotation.getIdentifier().equals(AnnotationIdentifierEnum.DEPRECATED.getValue())) {
				this.deprecated = true;
			} else if (annotation.getIdentifier().equals(AnnotationIdentifierEnum.LABEL.getValue())) {
				this.labels.add(annotation);
			} else if (annotation.getIdentifier().equals(AnnotationIdentifierEnum.DESCRIPTION.getValue())) {
				this.description.add(annotation);
			} else if (annotation.getIdentifier().equals(AnnotationIdentifierEnum.COMMENT.getValue())) {
				this.comments.add(annotation);
			} else {
				if (!this.identifierToAnnotation.containsKey(annotation.getIdentifier())) {
					this.identifierToAnnotation.put(annotation.getIdentifier(), new ArrayList());
				}

				((List) this.identifierToAnnotation.get(annotation.getIdentifier())).add(annotation);
			}
		}

	}

	public String toString() {
		return "Annotations{labels=" + this.labels + ", description=" + this.description + ", deprecated="
				+ this.deprecated + ", identifierToAnnotation=" + this.identifierToAnnotation + '}';
	}
}